// <copyright file="TabItemCollection.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System;
using System.Web.UI;

namespace YUIAspNet
{
    /// <summary>
    /// Collection of TabItem controls.
    /// </summary>
    public class TabItemCollection : ControlCollection
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TabItemCollection"/> class.
        /// </summary>
        /// <param name="owner">The owner.</param>
        public TabItemCollection(Control owner)
            : base(owner)
        {
        }

        /// <summary>
        /// Adds the specified <see cref="T:System.Web.UI.Control"/> object to the collection.
        /// </summary>
        /// <param name="child">The <see cref="T:System.Web.UI.Control"/> to add to the collection.</param>
        /// <exception cref="T:System.ArgumentNullException">Thrown if the <paramref name="child"/> parameter does not specify a control. </exception>
        /// <exception cref="T:System.Web.HttpException">Thrown if the <see cref="T:System.Web.UI.ControlCollection"/> is read-only. </exception>
        public override void Add(Control child)
        {
            if (!(child is TabItem))
                throw new ArgumentException("TabItemCollection can only contain TabItem controls.");
            base.Add(child);
        }

        /// <summary>
        /// Adds the specified <see cref="T:System.Web.UI.Control"/> object to the collection at the specified index location.
        /// </summary>
        /// <param name="index">The location in the array at which to add the child control.</param>
        /// <param name="child">The <see cref="T:System.Web.UI.Control"/> to add to the collection.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="child"/> parameter does not specify a control. </exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="index"/> parameter is less than zero or greater than the <see cref="P:System.Web.UI.ControlCollection.Count"/> property. </exception>
        /// <exception cref="T:System.Web.HttpException">The <see cref="T:System.Web.UI.ControlCollection"/> is read-only. </exception>
        public override void AddAt(int index, Control child)
        {
            if (!(child is TabItem))
            {
                throw new ArgumentException("TabItemCollection can only contain TabItem controls.");
            }
            base.AddAt(index, child);
        }

        /// <summary>
        /// Gets the <see cref="YUIAspNet.TabItem"/> at the specified index.
        /// </summary>
        /// <value></value>
        public new TabItem this[int index]
        {
            get { return (TabItem)base[index]; }
        }
    }
}
